//
//  BYHotCityView.m
//  ZhiHuiLiJiang
//
//  Created by Work on 2018/12/19.
//  Copyright © 2018年 WisdomLijiang. All rights reserved.
//

#import "BYHotCityView.h"

@implementation BYHotCityView


-(instancetype)init{
    if (self = [super init]) {
        [self addView];
    }
    return self;
}
-(void)addView{
    for (int i= 0; i<=5; i++) {
        
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.layer.borderWidth =0.5;
        btn.layer.borderColor = RGBA(152, 152, 152, 1).CGColor;
        btn.titleLabel.textColor =RGBA(40,40,40, 1);
        btn.titleLabel.font = H17;
        btn.layer.cornerRadius = 4;

        [btn sizeToFit];
        if (i<=2) {
            btn.frame = CGRectMake(10*(i+1)+((KSCREEWIDTH -40)/3)*i, 12, (KSCREEWIDTH -40)/3, 36);
        }
        else{
            btn.frame = CGRectMake(10*(i-2)+((KSCREEWIDTH -40)/3)*(i-3),60 , (KSCREEWIDTH -40)/3, 36);
            
        }
        if (i==0) {
            btn.titleLabel.text = @"丽江市";
            [btn setTitle:@"丽江市" forState:UIControlStateNormal];
        }
        if (i==1) {
            [btn setTitle:@"古城区" forState:UIControlStateNormal];

        }
        
        if (i==2) {
            [btn setTitle:@"玉龙县" forState:UIControlStateNormal];

        }
        if (i==3) {
            [btn setTitle:@"永胜县" forState:UIControlStateNormal];

        }
        if (i==4) {
            [btn setTitle:@"华坪县" forState:UIControlStateNormal];

        }
        if (i==5) {
            [btn setTitle:@"宁蒗县" forState:UIControlStateNormal];

            
        }
        [btn setTitleColor:RGBA(40,40,40, 1) forState:UIControlStateNormal];
        [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:btn];
        
    }
}
-(void)btnClick:(id)sender{
    UIButton *btn = (UIButton*)sender;
    if (self.delegate && [self.delegate respondsToSelector:@selector(BtnClckStr:)]) {
        [self.delegate BtnClckStr:btn.titleLabel.text];
    }
}
@end
